home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10660 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.4 KB

  1. Path: newsfeed.internetmci.com!xmission!news
  2. From: tknarr@xmission.com    ( Todd Knarr )
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Question: outLined inlines/ Vtab replication
  5. Date: 9 Mar 1996 03:43:57 GMT
  6. Organization: Chaos Central
  7. Message-ID: <4hqupt$ch1@news.xmission.com>
  8. References: <4hp08l$5sd@newdelph.cig.mot.com>
  9. Reply-To: tknarr@xmission.com   ( Todd Knarr )
  10. NNTP-Posting-Host: slc110.xmission.com
  11. X-Newsreader: IBM NewsReader/2 v1.2
  12.  
  13. In <4hp08l$5sd@newdelph.cig.mot.com>, Martin O'Hara <oharam> writes:
  14. >If a function is declared inline by the programmer but the address of this
  15. >function is taken in the code somewhere then the compiler will generate a
  16. >callable function. This may also happpen if the inline is recursive or too big.
  17.  
  18. >Q. Is a copy of such a function  placed in each translation unit in which it
  19. >is needed ( code duplication). Is this an "outlined inline"?
  20.  
  21. Yes and/or no. Most compilers probably include a seperate copy in each
  22. translation unit. A really smart compiler could detect this and suppress
  23. the duplication.
  24.  
  25. >Q. Can there exist inline expanded code representing the function and also a
  26. >callable version of the function in different parts of a program.? Or will the
  27. >compiler decide that if all occorrences of the function cannot be inline
  28. >expanded then the function will just be a normal one?
  29.  
  30. That depends on the compiler and how you compiled. If you're compiling with
  31. a traditional seperate-compilation compiler, the compiler has no knowledge
  32. of what happened in any other modules so it doesn't even realize that that
  33. inline function was outlined elsewhere. It will generally use one or the other
  34. within a module, but it's entirely permissible to vary from one module in a
  35. program to another.
  36.  
  37. If your compiler is such that it does keep track of the state of the entire
  38. program at all times, it may alter any module to conform to other modules.
  39. This is permissible but not required. The only thing that's required is that
  40. you can't put in two versions of the same inline function with different
  41. bodies ( although detecting this with a seperate-compilation compiler is
  42. highly non-trivial ).
  43.  
  44. --
  45. Todd Knarr : tknarr@xmission.com      |  finger for PGP public key
  46.                                       |  Member, USENET Cabal
  47.  
  48. Seriously, I don't want to die just yet.  I don't care how
  49. good-looking they are, I! don't! want! to! die!"
  50.                                         -- Megazone ( UF1 )
  51.  
  52.